package zgs;

import io.Person;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        String name = "王克晶";
        int age = 18;
        String gender = "女";
        String[] otherInfo ={"嗓门大","技术好","黑"};
        Person person = new Person(name,age,gender,otherInfo);
        System.out.println(person);

        FileOutputStream fos = new FileOutputStream("person.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        //对象流在进行对象序列化时，要求对象的类必须实现Serializable接口，否则会抛出NotSerializableException异常
        oos.writeObject(person);
        System.out.println("写出完毕");
        oos.close();

    }
}
